package com.mww.chatroom.controller;

import com.mww.chatroom.mapper.MessageMapper;
import com.mww.chatroom.model.Message;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@RestController
public class MessageController {
    @Resource
    private MessageMapper messageMapper;
@GetMapping("/message")
    public Object getMessage(int sessionId){
   List<Message> MessageList =  messageMapper.getMessagesBySessionId(sessionId);
   //针对查询结果进行逆置
    Collections.reverse(MessageList);
   return MessageList;

    }
}
